<?php
$this->pageTitle = Yii::t('site', 'Comments');
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile(Yii::app()->request->baseUrl.'/js/jquery.raty.js');
?>
<div class="ui-field-contain">
	<fieldset data-role="controlgroup" data-type="horizontal">
        <a href="<?php echo $this->createUrl('view', array('id'=>$model->getPrimaryKey())); ?>"><?php echo CHtml::encode($model->name); ?></a>
        <a id="star" data-score="<?php echo $model->rating; ?>" class="ui-btn-inline"></a>
        (<?php echo $dataProvider->getTotalItemCount(); ?>)
	</fieldset>
</div>

<?php
if ($dataProvider->getTotalItemCount() > 0) {
    $this->widget('ext.mobile.ListView', array(
        'dataProvider'=>$dataProvider,
        'dividerName'=>$dividerName,
        'itemView'=>'_viewComment',
    ));
?>

<script>
$('#mainPage').on('pageshow', function () {
    $('#star').raty({
        path: "<?php echo Yii::app()->request->baseUrl; ?>/images/",
        readOnly: true,
        halfShow : true,
        score: function() {
            return $(this).attr('data-score');
        }
    });
    
    $("div[name='star']" ).each(function() {
        $(this).raty({
            path: "<?php echo Yii::app()->request->baseUrl; ?>/images/",
            readOnly: true,
            score: function() {
                return $(this).attr('data-score');
            }
        });
    });
});
</script>
<?php } ?>